/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.sip;

import java.net.DatagramPacket;
import javamail.conn.udpSocket;

/**
 *
 * @author sriram
 */
public class sipUA extends Thread {
    private static final boolean debugEnabled = true;
    private int port = 0;

    public sipUA() {
        this.port = javamail.main.glblConfig.getSipPort();
    }

    @Override
    public void run() {
        DatagramPacket temp = null;
        String msg = null;
        // Open up the SIP server UDP port
        udpSocket sock = new udpSocket(port);
        if(sock==null || sock.error==true) {
            System.err.println("SIP UDP socket not created! Exiting Application");
            return;
        }
        if(debugEnabled)
            System.out.println("sipUA::run-Started SIP server on port: "+port);

        // Start the Receive thread so that the SIP UA can start receiving data
        // on the socket.
        sipUAReceive receiveThread = new sipUAReceive(sock);
        receiveThread.start();
        // Start the Send thread so that the SIP UA can start sending data
        sipUASend sendThread = new sipUASend(sock);
        sendThread.start();
    }

}

